// 公共类型声明

import Vue from 'vue'
import App from './App.vue'
import router from './router/index'
import { store } from './store/index'
import iview from 'iview'
import '@/components/style/custom.less';
import '@/components/style/main.scss';
import '@/components/ivew_components/components_introduce.ts';
import Vuex from 'vuex'


Vue.use(Vuex);
Vue.use(iview);

Vue.config.productionTip = false

/* eslint-disable no-new */
const app = new Vue({
  
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>',
  
  created (){

    // 初次加载，跳转至登陆（请求ukey）
    const ukey = sessionStorage.getItem('ukey') || '';
    const store = this.$store;
    const _vue = this;
   
    if(!ukey){

      router.push('/sign-in')
      
    }else{
      
      // 提取会话数据
      let userInfo = JSON.parse(sessionStorage.getItem('userInfo'));
      store.commit('mainStore/updateUserBase', userInfo)
      store.dispatch('mainStore/setPowerConf', userInfo.acl)
    }

    // 提取本地数据
    this.$store.dispatch('localStore/initSet')
    
  }

})


export default app 